package com.opgea.tutor.dao.impl;

import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.opgea.tutor.dao.AbstractDAO;
import com.opgea.tutor.dao.EducationDAO;
import com.opgea.tutor.domain.entities.Education;

@Repository
public class EducationDAOImpl extends AbstractDAO<Education> implements EducationDAO{

    @Autowired
    private SessionFactory sessionFactory;
    
    @Override
    public Education find(long id) {
	Query query = sessionFactory.getCurrentSession().createQuery("from Education e WHERE e.id = :id");
	query.setParameter("id", id);
	if (query.list() != null && query.list().size() > 0) {
	    return (Education) query.list().get(0);
	} else {
	    return null;
	}
    }
}
